from Liner_Regress.model import LinerModel
from Decision_Tree.index import DecisionTree
from Liner_Regress.model import MutiplyRegressModel
from sklearn.model_selection import train_test_split
import pandas as pd
from Utils.index import TransformLuoma


if __name__ == "__main__":
    # 测试数据
    # x = [[2024, 1, 17, 5], [2024, 1, 18, 6], [2024, 1, 19, 7], [2024, 1, 20, 1], [2024, 1, 21, 2],
    #            [2024, 1, 22, 3], [2024, 1, 23, 4], [2024, 1, 24, 5], [2024, 1, 25, 6], [2024, 1, 26, 7],
    #            [2024, 1, 27, 1], [2024, 1, 28, 2], [2024, 1, 29, 3], [2024, 1, 30, 4], [2024, 1, 31, 5],
    #            [2024, 2, 1, 6]]
    # y = [11, 12, 16, 17, 16, 14, 15, 14, 7, 4, 8, 8, 12, 11, 8, 4]
    # mlr = MutiplyRegressModel()
    # train_x,test_x,train_y,test_y = train_test_split(x,y,test_size=0.2,random_state=1)
    # mlr.fit(train_x,train_y)
    # print([float(value) for value in mlr.predicts(test_x)])
    DF = pd.read_csv("./assets/water_data.cvs")
    X,y = [],[]
    for i in range(len(DF)):
        X.append([DF.loc[i]["水温"],DF.loc[i]["ph值"],DF.loc[i]["溶解氧"],DF.loc[i]["电导率"],DF.loc[i]["浊度"],DF.loc[i]["总磷"],DF.loc[i]["总氮"]])
        y.append(TransformLuoma(DF.loc[i]["水质"]))
    DT = DecisionTree()
    train_x, test_x, train_y, test_y = train_test_split(X, y, test_size=0.1, random_state=1)
    DT.fit(train_x,train_y)
    print(f"测试数据准确率为{DT.score(test_x,test_y)*100}%")
    print("预测水温3.6、ph值8、溶解氧14.1、电导率617.7、浊度4.4、总磷0.019、总氮6.42的水质类别为：",end="")
    print(TransformLuoma(DT.forecast([2.2,8,14.1,46068.9,12.3,0.029,3.32])))